## DESCRIPTION
## Differential calculus: answer is a number or formula with units
## ENDDESCRIPTION

## KEYWORDS('differential calculus', 'units')

## DBsubject('WeBWorK')
## DBchapter('WeBWorK Tutorial')
## DBsection('Fort Lewis Tutorial 2011')
## Date('01/30/2011')
## Author('Paul Pearson')
## Institution('Fort Lewis College')
## TitleText1('')
## EditionText1('')
## AuthorText1('')
## Section1('')
## Problem1('')


##############################
#  Initialization

DOCUMENT(); 

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserNumberWithUnits.pl",
"parserFormulaWithUnits.pl",
);

TEXT(beginproblem());


#############################
#  Setup

Context("Numeric")->variables->are(t=>"Real");

$h = Formula("-16 t^2 + 16");
$v = $h->D('t');
$v1 = $v->eval(t=>1);
$a = $v->D('t');

$answer[0] = FormulaWithUnits("$v","ft/s");
$answer[1] = NumberWithUnits("$v1","ft/s");
$answer[2] = FormulaWithUnits("$a","ft/s^2");


#############################
#  Main text

Context()->texStrings;
BEGIN_TEXT
Suppose the height of a falling object, in feet
above the ground, is given by \( h(t) = $h \) 
for \( t \geq 0 \), where time is measured in 
seconds.
$BR
$BR
(a) What is the velocity of the object?  Include
units in your answer.
$BR
\{ ans_rule(20) \}
\{ helpLink("units") \}
$BR
$BR
(b) What is the velocity of the object when it
hits the ground?  Include units in your answer. 
$BR
\{ ans_rule(20) \}
\{ helpLink("units") \}
$BR
$BR
(c) What is the acceleration of the object?  
Include units in your answer. 
$BR
\{ ans_rule(20) \}
\{ helpLink("units") \}
END_TEXT
Context()->normalStrings;


############################
#  Answers

$showPartialCorrectAnswers = 1;

foreach my $i (0..2) {
  ANS( $answer[$i]->cmp() );
}

############################
#  Solution

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT("MathObject version.");

ENDDOCUMENT();





###########################
#  Initialization


DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserDifferenceQuotient.pl",
);

TEXT(beginproblem());


###########################
#  Setup

Context("Numeric");

$limit = DifferenceQuotient("2*x+h","h");

$fp = Compute("2 x");


###########################
#  Main text

Context()->texStrings;
BEGIN_TEXT
Simplify and then evaluate the limit.
$BR
$BR
\( \displaystyle 
\frac{d}{dx} \big( x^2 \big) 
=
\lim_{h \to 0} \frac{(x+h)^2-x^2}{h} 
= 
\lim_{h \to 0} 
\big(
\)
\{ ans_rule(15) \}
\( \big) = \)
\{ ans_rule(15) \}
END_TEXT
Context()->normalStrings;


############################
#  Answer evaluation

$showPartialCorrectAnswers = 1;

ANS( $limit->cmp() );
ANS( $fp->cmp() );


############################
#  Solution

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();
